home *** CD-ROM | disk | FTP | other *** search
/ PC Media 23 / PC MEDIA CD23.iso / share / prog / newmat / newmata.txt < prev    next >
Encoding:
Text File  |  1995-01-19  |  69.0 KB  |  1,882 lines

  1.  
  2.  
  3.         DOCUMENTATION FOR NEWMAT08, A MATRIX LIBRARY IN C++
  4.  
  5. Copyright (C) 1991,2,3,4,5: R B Davies
  6.  
  7. This is the "how to use" documentation for newmat. Background information on
  8. the structure of the library is given in newmatb.txt and information about the
  9. test program is in newmatc.txt.
  10.  
  11. This document is available as an ascii file, newmata.txt, and in hypertext
  12. format for reading with "Mosaic". Cross-references in the ascii version are
  13. given as section numbers.
  14.  
  15.  
  16.         Introduction                                 1
  17.         Getting started                              2
  18.         Reference manual                             3
  19.         Error messages                               4
  20.         Bugs                                         5
  21.         Files in newmat08                            6
  22.         Problem report form                          7
  23.  
  24.  
  25.         1  Introduction
  26.         =  ============
  27.  
  28.         Conditions of use                            1.1
  29.         Description                                  1.2
  30.         Is this the library for you?                 1.3
  31.         Other matrix libraries                       1.4
  32.         Where to find this library                   1.5
  33.         How to contact the author                    1.6
  34.         Change history                               1.7
  35.         References                                   1.8
  36.  
  37.  
  38.         1.1  Conditions of use
  39.         ===  ========== == ===
  40.  
  41. Copyright (C) 1991,2,3,4,5: R B Davies.
  42.  
  43. Permission is granted to use and distribute but not to sell except for costs
  44. of distribution. Distribution as part of low cost CD-ROM collections is
  45. welcomed.
  46.  ------------------------------------------------------------------------------
  47. Please understand that there may still be bugs and errors. Use at your own
  48. risk. I take no responsibility for any errors or omissions in this package or
  49. for any misfortune that may befall you or others as a result of its use.
  50.  ------------------------------------------------------------------------------
  51.  
  52. Please report bugs to me at
  53.  
  54.     robert.davies@vuw.ac.nz
  55.  
  56. or
  57.  
  58.     Compuserve 72777,656
  59.  
  60. When reporting a bug please tell me which C++ compiler you are using (if
  61. known), and what version. Also give me details of your computer (if known).
  62. Tell me where you downloaded your version of my package from and its version
  63. number (eg newmat03 or newmat04). (There may be very minor differences between
  64. versions at different sites). Note any changes you have made to my code. If at
  65. all possible give me a piece of code illustrating the bug. See the problem
  66. report form [7].
  67.  
  68. "Please do report bugs to me."
  69.  
  70.  
  71.  
  72.         1.2  General description
  73.         ===  ======= ===========
  74.  
  75. The package is intended for scientists and engineers who need to manipulate a
  76. variety of types of matrices using standard matrix operations. Emphasis is on
  77. the kind of operations needed in statistical calculations such as least
  78. squares, linear equation solve and eigenvalues.
  79.  
  80. It supports matrix types
  81.  
  82.     Matrix                       (rectangular matrix)
  83.     nricMatrix                   (variant of rectangular matrix)
  84.     UpperTriangularMatrix
  85.     LowerTriangularMatrix
  86.     DiagonalMatrix
  87.     SymmetricMatrix
  88.     BandMatrix
  89.     UpperBandMatrix              (upper triangular band matrix)
  90.     LowerBandMatrix              (lower triangular band matrix)
  91.     SymmetricBandMatrix
  92.     RowVector                    (derived from Matrix)
  93.     ColumnVector                 (derived from Matrix).
  94.  
  95. Only one element type (float or double) is supported.
  96.  
  97. The package includes the operations *, +, -, concatenation, inverse,
  98. transpose, conversion between types, submatrix, determinant, Cholesky
  99. decomposition, QR triangularisation, singular value decomposition, eigenvalues
  100. of a symmetric matrix, sorting, fast Fourier transform, printing and an
  101. interface with "Numerical Recipes in C".
  102.  
  103. It is intended for matrices in the range 15 x 15 to the maximum size your
  104. machine will accomodate in a single array. For example 90 x 90 (125 x 125 for
  105. triangular matrices) in machines that have 8192 doubles as the maximum size of
  106. an array. The number of elements in an array cannot exceed the maximum size of
  107. an "int". The package will work for very small matrices but becomes rather
  108. inefficient.
  109.  
  110. A two-stage approach to evaluating matrix expressions is used to improve
  111. efficiency and reduce use of temporary storage.
  112.  
  113. The package is designed for version 2 or 3 of C++. It works with Borland (3.1
  114. & 4.0), Microsoft (7 & 8) and Watcom (10) C++ on a PC and AT&T C++ (2.1 & 3)
  115. and Gnu G++ (2.3.3, 2.5.8 & 2.6.0). It works with some problems with Zortech
  116. C++ (version 3.04).
  117.  
  118.  
  119.  
  120.         1.3  Is this the library for you?
  121.         ===  == ==== === ======= === ====
  122.  
  123. Do you
  124.  
  125. 1:  understand * to mean matrix multiply and not element by element multiply
  126.  
  127. 2:  need matrix operators such as * and + defined as operators so you can
  128. write things like
  129.  
  130.     X  = A * (B + C);
  131.  
  132. 3:  need a variety of types of matrices (but not sparse)
  133.  
  134. 4:  need only one element type (float or double)
  135.  
  136. 5:  work with matrices in the range 10 x 10 up to what can be stored in one
  137. block in memory
  138.  
  139. 6:  tolerate a large package
  140.  
  141.  
  142. Then maybe this is the right package for you. 
  143.  
  144.  
  145.  
  146.         1.4  Other matrix libraries
  147.         ===  ===== ====== =========
  148.  
  149. For commercial packages that support multiple element types, look at M++ from
  150. Dyad [phone in the USA (800)366-1573, (206)637-9427, fax (206)637-9428], or
  151. the Rogue Wave matrix package [(800)487-3217, (503)754-3010, fax
  152. (503)757-6650].
  153.  
  154. For details of other matrix packages look at the listing from Keith Briggs. A
  155. recent version of this is in file kbriggs.txt included with this package. Also
  156. look at Ajay Shah's list of free numerical software in C and C++. The file is
  157. numcomp-free-c.gz in pub/C-numanal on usc.edu. Nikki Locke produces a list of
  158. C++ libraries in general - see
  159. pub/usenet-by-group/comp.lang.c++/c++_FAQ/libraries in rtfm.mit.edu. 
  160.  
  161. Also look on Compuserve in the forums of the various C++ compilers.
  162.  
  163.  
  164.  
  165.         1.5  Where to find this library
  166.         ===  ===== == ==== ==== =======
  167.  
  168.  
  169. *   Compuserve (Borland library, zip format)
  170.  
  171. *   SimTel (msdos.cpluspls directory, zip format) - see oak.oakland.edu
  172.  
  173. *   comp.sources.misc on Internet (shar format) - see wuarchive.wustl.edu
  174.  
  175.  
  176.  
  177.  
  178.         1.6  How to contact the author
  179.         ===  === == ======= === ======
  180.  
  181.  
  182.    Robert Davies
  183.    16 Gloucester Street
  184.    Wilton
  185.    Wellington
  186.    New Zealand
  187.  
  188.    "email:" robert.davies@vuw.ac.nz
  189.  
  190.  
  191.  
  192.  
  193.         1.7  Change history
  194.         ===  ====== =======
  195.  
  196. Newmat08 - January, 1995:
  197.  
  198. Corrections to improve compatibility with Gnu, Watcom. Concatenation of
  199. matrices. Elementwise products. Option to use compilers supporting exceptions.
  200. Correction to exception module to allow global declarations of matrices. Fix
  201. problem with inverse of symmetric matrices. Fix divide-by-zero problem in SVD.
  202. Include new QR routines. Sum function. Non-linear optimisation.
  203. GenericMatrices.
  204.  
  205. Newmat07 - January, 1993
  206.  
  207. Minor corrections to improve compatibility with Zortech, Microsoft and Gnu.
  208. Correction to exception module. Additional FFT functions. Some minor increases
  209. in efficiency. Submatrices can now be used on RHS of =. Option for allowing C
  210. type subscripts. Method for loading short lists of numbers.
  211.  
  212.  
  213. Newmat06 - December 1992:
  214.  
  215. Added band matrices; 'real' changed to 'Real' (to avoid potential conflict in
  216. complex class); Inject doesn't check for no loss of information;  fixes for
  217. AT&T C++ version 3.0; real(A) becomes A.AsScalar(); CopyToMatrix becomes
  218. AsMatrix, etc; .c() is no longer required (to be deleted in next version);
  219. option for version 2.1 or later. Suffix for include files changed to .h; BOOL
  220. changed to Boolean (BOOL doesn't work in g++ v 2.0); modifications to allow
  221. for compilers that destroy temporaries very quickly; (Gnu users - see the
  222. section of compiler performance). Added CleanUp, LinearEquationSolver,
  223. primitive version of exceptions.
  224.  
  225.  
  226. Newmat05 - June 1992:
  227.  
  228. For private release only 
  229.  
  230.  
  231. Newmat04 - December 1991:
  232.  
  233. Fix problem with G++1.40, some extra documentation
  234.  
  235.  
  236. Newmat03 - November 1991:
  237.  
  238. Col and Cols become Column and Columns. Added Sort, SVD, Jacobi, Eigenvalues,
  239. FFT, real conversion of 1x1 matrix, "Numerical Recipes in C" interface, output
  240. operations, various scalar functions. Improved return from functions.
  241. Reorganised setting options in "include.hxx".
  242.  
  243.  
  244. Newmat02 - July 1991:
  245.  
  246. Version with matrix row/column operations and numerous additional functions.
  247.  
  248.  
  249. Matrix - October 1990:
  250.  
  251. Early version of package.
  252.  
  253.  
  254.  
  255.         1.8  References
  256.         ===  ==========
  257.  
  258. The matrix inverse routine and the sort routines are adapted from "Numerical
  259. Recipes in C" by Press, Flannery, Teukolsky, Vetterling, published by the
  260. Cambridge University Press.
  261.  
  262. Many of the advanced matrix routines are adapted from routines in "Handbook
  263. for Automatic Computation, Vol II, Linear Algebra" by Wilkinson and Reinsch,
  264. published by Springer Verlag.
  265.  
  266.  
  267.  
  268.         2  Getting started
  269.         =  ======= =======
  270.  
  271.         Overview                                     2.1
  272.         Customising                                  2.2
  273.         Compiler performance                         2.3
  274.         Updating from previous versions              2.4
  275.         Example                                      2.5
  276.         Testing                                      2.6
  277.  
  278.  
  279.  
  280.  
  281.  
  282.         2.1  Overview
  283.         ===  ========
  284.  
  285. I use .h as the suffix of definition files and .cpp as the suffix of C++
  286. source files.
  287.  
  288. You will need to compile all the *.cpp files except example.cpp, the tmt*.cpp
  289. files, sl_ex.cpp and ex_nl.cpp to get the complete package. Ideally you should
  290. store the resulting object files as a library. The tmt*.cpp files are used for
  291. testing [2.6], example.cpp is an example [2.5] and sl_ex.cpp and ex_nl.cpp are
  292. examples of the non-linear [3.26] solve and optimisation routines.
  293.  
  294. I include a number of "make" files for compiling the example and the test
  295. package. See the files section [6] for details. But with Borland and Watcom,
  296. its pretty quick just to load all the files in the interactive environment by
  297. pointing and clicking. My Borland "make" files are generated from the
  298. interactive environment.
  299.  
  300. Use the large or flat model when you are using a PC. Do not "outline" inline
  301. functions. You may need to increase the stack size.
  302.  
  303. The "make" files for the Unix compilers link a .cxx file to each .cpp file
  304. since some of these compilers do not recognise .cpp as a legitimate extension
  305. for a C++ file. I suggest you delete this part of the "make" file and rename
  306. the .cpp files to something your compiler recognises.
  307.  
  308. My "make" files for Unix systems are for use with 'gmake' rather than 'make'.
  309. Ordinary 'make' works with them on the Sun but not the Silicon Graphics or HP
  310. machines. 
  311.  
  312. Your source files that access the newmat you will need to #include one or more
  313. of the following files.
  314.  
  315. include.h:
  316.    if you want to access just the compiler options
  317.  
  318. newmat.h:
  319.    to access just the main matrix library (includes include.h)
  320.  
  321. newmatap.h:
  322.    to access the advanced matrix routines such as Cholesky decomposition, QR
  323. triangularisation etc (includes newmat.h)
  324.  
  325. newmatio.h:
  326.    to access the output routines (includes newmat.h) You can use this only
  327. with compilers that support the standard input/output routines including
  328. manipulators. It cannot be used with Zortech or early versions of Gnu.
  329.  
  330. newmatnl.h:
  331.    to access the non-linear optimisation routines (includes newmat.h)
  332.  
  333.  
  334.  
  335. See the section on customising [2.2] to see how to edit include.h for your
  336. environment and the section on compilers [2.3] for any special problems with
  337. the compiler you are using.
  338.  
  339.  
  340.  
  341.  
  342.         2.2  Customising
  343.         ===  ===========
  344.  
  345. The file  include.h  sets a variety of options including several compiler
  346. dependent options. You may need to edit include.h to get the options you
  347. require. If you are using a compiler different from one I have worked with you
  348. may have to set up a new section in  include.h  appropriate for your compiler.
  349.  
  350. Borland, Turbo, Gnu, Microsoft, Watcom and Zortech are recognised
  351. automatically. If none of these are recognised a default set of options is
  352. used. These are fine for AT&T, HPUX and Sun C++. If you using a compiler I
  353. don't know about you may have to write a new set of options.
  354.  
  355. Activate the appropriate statement to make the element type float or double.
  356.  
  357. If you are using the standard style for deleting arrays (AT&T version 2.1 or
  358. later) make sure Version21 is #defined. If you are using the old style, make
  359. sure it is not #defined.
  360.  
  361. There is an option in include.h for selecting whether you use compiler
  362. supported exceptions, simulated exceptions, or disable exceptions. Use the
  363. option for compiler supported exceptions if and only if you have set the
  364. option on your compiler to recognise exceptions. Disabling exceptions
  365. sometimes helps with compilers that are incompatible with my exception
  366. simulation scheme.
  367.  
  368. I suggest you leave the option TEMPS_DESTROYED_QUICKLY activated, even though
  369. the Gnu compiler is the only one I know about that requires it. This stores
  370. the "trees" dsecribing matrix expressions on the heap rather than the stack
  371. and, surprisingly, seems to give better performance. See the discussion in
  372. newmatb.txt for more explanation.
  373.  
  374. Leave the option TEMPS_DESTROYED_QUICKLY_R not activated unless you are using
  375. the Gnu G++ [2.3.3] compiler. This option controls whether the ReturnMatrix
  376. [3.13] construct uses the stack or the heap. The heap version is rather kludgy
  377. and probably should be avoided where possible.
  378.  
  379. The option DO_FREE_CHECK is used for tracking memory leaks and normally should
  380. not be activated.
  381.  
  382. Activate SETUP_C_SUBSCRIPTS if you want to use traditional C style element
  383. access [3.2]. 
  384.  
  385.  
  386.  
  387.  
  388.         2.3  Compiler performance
  389.         ===  ======== ===========
  390.  
  391. I have tested this library on a number of compilers. Here are the levels of
  392. success and any special considerations. In most cases I have chosen code that
  393. works under all the compilers I have access to, but I have had to include some
  394. specific work-arounds for some compilers. For the MsDos versions, I use a
  395. 486dx computer running MsDos 6 or windows NT. The unix versions are on a Sun
  396. Sparc station or a Silicon Graphics or a HP unix workstation. Thanks to
  397. Victoria University and Industrial Research Ltd for access to the Unix
  398. machines.
  399.  
  400. I have set up a block of code for each of the compilers in include.h. Turbo,
  401. Borland, Gnu, Zortech, Microsoft and Watcom are recognised automatically.
  402. There is a default option that works for AT&T, Sun C++ 4.0.1 and HPUX. So you
  403. don't have to make any changes for these compilers. Otherwise you may have to
  404. build your own set of options in include.h.
  405.  
  406.         AT&T                                         2.3.1
  407.         Borland                                      2.3.2
  408.         Gnu G++                                      2.3.3
  409.         HPUX                                         2.3.4
  410.         Microsoft                                    2.3.5
  411.         Sun                                          2.3.6
  412.         Watcom                                       2.3.7
  413.         Zortech                                      2.3.8
  414.  
  415.  
  416.  
  417.  
  418.         2.3.1  AT&T
  419.         =====  ====
  420.  
  421. AT&T C++ 2.1;3.0.1 on a Sun: It works fine with 3.0.1. I haven't been able to
  422. test the latest version of the library on 2.1. The previous version worked
  423. fine. Except aggregates are not supported in 2.1 and setjmp.h generated a
  424. warning message. If you are using "interviews" you may get a conflict with
  425. Catch. Either #undefine Catch or replace Catch with CATCH throughout my
  426. package. In AT&T 2.1 you may get an error when you use an expression for the
  427. single argument when constructing a Vector or DiagonalMatrix or one of the
  428. Triangular Matrices. You need to evaluate the expression separately.
  429.  
  430. You cannot run my non-linear [3.26] package with these compilers, because of
  431. my use of labels.
  432.  
  433.  
  434.  
  435.         2.3.2  Borland
  436.         =====  =======
  437.  
  438. Borland C++ 3.1, 4.5: Recently this has been my main development platform, so
  439. naturally everything works with this compiler. There was a problem with the
  440. library utility in version 2.0 which is now fixed. You will need to use the
  441. large model. If you are not debugging, turn off the options that collect
  442. debugging information. Make sure you don't run Borland's exceptions and my
  443. simulated exceptions at the same time.
  444.  
  445. When running my test program with Borland 4.5 under ms-dos you may run out of
  446. memory. Either compile the test routine to run under "easywin" or use
  447. simulated exceptions rather than the built in exceptions. Under "easywin" the
  448. test program indicates a memory leak. I presume this is partly because of the
  449. way windows organises its heap rather than there being a real problem.
  450.  
  451. However there does seem to be genuine memory problem when you use the built-in
  452. exceptions. Under "easywin" the automatic clean-up of objects by the exception
  453. mechanism does not seem to work. Use my simulated exceptions if this is a
  454. problem.
  455.  
  456.  
  457.  
  458.         2.3.3  Gnu G++
  459.         =====  === ===
  460.  
  461. Gnu G++ 2.3.3, 2.5.8:  These mostly work. You must enable the options
  462. TEMPS_DESTROYED_QUICKLY and TEMPS_DESTROYED_QUICKLY_R. You can't use
  463. expressions like Matrix(X*Y) in the middle of an expression and (Matrix)(X*Y)
  464. is unreliable. If you write a function returning a matrix, you MUST use the
  465. ReturnMatrix [3.13] method described in this documentation. This is because
  466. g++ destroys temporaries occuring in an expression too soon for the two stage
  467. way of evaluating expressions that newmat uses.  Gnu seems to leave some
  468. rubbish on the stack. Possibly this is a printer buffer so it may not be a
  469. bug. You will have problems with versions of Gnu earlier than 2.3.1.
  470.  
  471. Linux: Gnu G++ 2.5.8 seems a little more touchy than regular G++. But
  472. basically the package works.
  473.  
  474. Gnu G++ 2.6.0: Seems OK. There should be better compatibility because version
  475. 2.6 retains temporaries until the end of the statement instead of destroying
  476. them immediately following the first access. I suggest you enable option
  477. TEMPS_DESTROYED_QUICKLY but not TEMPS_DESTROYED_QUICKLY_R.
  478.  
  479.  
  480.  
  481.         2.3.4  HP-UX
  482.         =====  =====
  483.  
  484. HP 9000 series HP-UX. I have tried the library on two versions of HP-UX. (I
  485. don't know the version numbers, the older is a clone of AT&T 3, the newer is
  486. HP's version with exceptions). Both worked after the modifications described
  487. in this section except that I couldn't compile the non-linear [3.26] package
  488. due to my use of labels.
  489.  
  490. With the older version of the compiler I needed to edit the math.h library
  491. file to remove a duplicate definition of abs.
  492.  
  493. With the newer version you can set the +eh option to enable exceptions and
  494. activate the UseExceptions option in include.h. If you are using my make file,
  495. you will need to replace CC with CC +eh where ever CC occurs. I recommend that
  496. you do not do this and either disable exceptions or use my simulated
  497. exceptions. I get core dumps when I use the built-in exceptions and suspect
  498. they are not sufficiently debugged as yet.
  499.  
  500. If you are using my simulated exceptions you may get a mass of error messages
  501. from the linker about __EH_JMPBUF_TEMP. In this case get file setjmp.h (in
  502. directory /usr/include/CC ?) and put extern in front of the line
  503.  
  504.    jmp_buf * __EH_JMPBUF_TEMP;
  505.  
  506. The file setjmp.h is accessed in my file myexcept.h. You may want to change
  507. the #include statement to access your edited copy of setjmp.h.
  508.  
  509.  
  510.  
  511.         2.3.5  Microsoft
  512.         =====  =========
  513.  
  514. Microsoft C++ (7.0, 8.0): Seems to work OK. You must #define
  515. TEMPS_DESTROYED_QUICKLY owing to a bug in version 7 (at least) of MSC. There
  516. are some notes in the file include.h on changes to run under version 7. I
  517. haven't tried the latest version of newmat08 on version 7.
  518.  
  519. Haven't tried visual C++ yet.
  520.  
  521.  
  522.  
  523.  
  524.         2.3.6  Sun
  525.         =====  ===
  526.  
  527. Sun C++ (version 4.0.1): This generally works fine. However, I suspect that
  528. there is a problem with my non-linear [3.26] package, even though the program
  529. appears to run correctly, probably because of my use of labels. When I set
  530. DO_FREE_CHECK, I detect non-existent objects being deleted and the program
  531. fails if I use simulated exceptions.
  532.  
  533.  
  534.  
  535.         2.3.7  Watcom
  536.         =====  ======
  537.  
  538. Watcom C++ (version 10): basically this works fine. Don't try to run Watcom's
  539. exceptions and my simulated exceptions at the same time.
  540.  
  541. There does seem to be a problem with expressions such as
  542.  
  543.    X = Matrix(A+B)+C;
  544.  
  545. Occasionally the temporary object created by Matrix(A+B) is destroyed twice.
  546. In most cases this does not seem to cause a problem. However, I think one
  547. should avoid code such as this - in fact, there is generally not much point to
  548. such code. Alternatively use my simulated exceptions as the problem seems to
  549. occur only with the built in exceptions enabled. 
  550.  
  551.  
  552.  
  553.         2.3.8  Zortech
  554.         =====  =======
  555.  
  556. Zortech C++ 3.04: "const" doesn't work correctly with this compiler, so the
  557. package skips all of the statements Zortech can't handle. Zortech leaves
  558. rubbish on the heap. I don't know whether this is my programming error or a
  559. Zortech error or additional printer buffers. Deactivate the option for version
  560. 2.1 in include.h. Does not support IO manipulators. Otherwise the package
  561. mostly works, but not completely. Best don't #define TEMPS_DESTROYED_QUICKLY.
  562. Exceptions and the nric interface don't work. I think some of the problems are
  563. because Zortech doesn't handle conversions correctly, particularly automatic
  564. conversions. But, also newmat is just too big for my version of Zortech.
  565. Zortech runs much more slowly than Borland and Microsoft. Use the large model
  566. and compile as much as possible with optimisation on to save space. You won't
  567. be able to get the whole test program to work. Zortech doesn't have
  568. io-manipulators so you can't compile the example.
  569.  
  570. I haven't tried the Symantec successors to Zortech.
  571.  
  572.  
  573.  
  574.  
  575.  
  576.         2.4  Updating newmat08
  577.         ===  ======== ========
  578.  
  579.         Updating from previous 08 betas               2.4.1
  580.         Updating from previous versions               2.4.2
  581.  
  582.  
  583.         2.4.1  Updating from previous 08 betas
  584.         =====  ======== ==== ======== == =====
  585.  
  586.  
  587. If you were using the non-linear optimisation routine in an previous beta,
  588. note that rowvectors and columnvectors have been swapped in this version of
  589. newmatnl. You now derive from prototype function classes rather than the
  590. solution and least squares classes. Simple examples are included with the
  591. library.
  592.  
  593. This version includes concatenation operators, elementwise products for
  594. matrices and GenericMatrices. See the sections on binary operators [3.6] and
  595. unspecified types [3.16].
  596.  
  597. There is now no need to explicitly set the AT&T option in include.h.
  598.  
  599. I have reorganised the make files for AT&T, Gnu, Microsoft and Watcom. See the
  600. files [6] section.
  601.  
  602.  
  603.         2.4.2  Updating form previous versions
  604.         =====  ======== ==== ======== ========
  605.  
  606. This is a minor upgrade on newmat07 to correct errors (one serious) and
  607. improve compatibility with various compilers. You should upgrade.
  608.  
  609. *  .cxx files are now .cpp files. Some versions of won't accept .cpp. The
  610. "make" files for Gnu and AT&T link the .cpp files to .cxx files before
  611. compilation and delete the links after compilation.
  612.  
  613. *  An option [2.2] in include.h allows you to use compiler supported
  614. exceptions, simulated exceptions or disable exceptions. Edit the file
  615. include.h to select one of these three options. Don't simulate exceptions if
  616. you have set your compiler's option to implement exceptions.
  617.  
  618. *  New QR decomposition [3.18] functions.
  619.  
  620. *  A non-linear least squares [3.26] class.
  621.  
  622. *  No need to explicitly set the AT&T option in include.h.
  623.  
  624. *  Concatenation and elementwise multiplication [3.6].
  625.  
  626. *  A new GenericMatrix [3.16] class.
  627.  
  628. *  Sum [3.8] function.
  629.  
  630. *  Some of the make [6] files reorganised. 
  631.  
  632.  
  633. If you are upgrading from newmat06 note the following:
  634.  
  635. *  If you are using << to load a Real into a submatrix change this to =.
  636.  
  637.  
  638. If you are upgrading from newmat03 or newmat04 note the following
  639.  
  640. *  .hxx files are now .h files
  641.  
  642. *  real changed to Real
  643.  
  644. *  BOOL changed to Boolean
  645.  
  646. *  CopyToMatrix changed to AsMatrix, etc
  647.  
  648. *  real(A) changed to A.AsScalar()
  649.  
  650.  
  651. The current version is quite a bit longer that newmat04, so if you are almost
  652. out of space with newmat04, don't throw newmat04 away until you have checked
  653. your program will work under this version.
  654.  
  655. See the change history [1.7] for other changes.
  656.  
  657.  
  658.         2.5  Example
  659.         ===  =======
  660.  
  661. An example is given in  example.cpp.  This gives a simple linear regression
  662. example using four different algorithms. The correct output is given in
  663. example.txt. The program carries out a rough check that no memory is left
  664. allocated on the heap when it terminates. See the section on testing [2.6] for
  665. a comment on the reliability of this check and the use of the DO_FREE_CHECK
  666. option.
  667.  
  668. I include a variety of make files. Use a command like
  669.  
  670.    gmake example -f gnu.mak               (Gnu G++)
  671.    gmake example -f cc.mak                (AT&T, HPUX, Sun)
  672.    nmake example -f ms_nt.mak             (Microsoft C++ 8.0)
  673.    make -f ex_b.mak                       (Borland C++ 3.1)
  674.    make -f ex_bc45.mak                    (Borland C++ 4.5)
  675.    wmake example.exe -f watcom.mak        (Watcom C++ 10A)
  676.    wmake example.exe -f watco_nt.mak      (Watcom C++ 10A)
  677.  
  678. The Borland files were derived from the project file and you will have to edit
  679. these to suit your environment. The file ex_bc45.mak is for making a windows
  680. NT executable program. The Microsoft file is for the version of C++ that came
  681. with the Windows NT 3.1 development kit. The second Watcom file is for making
  682. a Windows NT executable.
  683.  
  684.  ------------------------------------------------------------------------------
  685. This example uses io manipulators. It will not work with a compiler that does
  686. not support the standard io manipulators.
  687.  ------------------------------------------------------------------------------
  688.  
  689.  
  690.  
  691.         2.6  Testing
  692.         ===  =======
  693.  
  694. The library package contains a comprehensive test program in the form of a
  695. series of files with names of the form tmt?.cxx. The files consist of a large
  696. number of matrix formulae all of which evaluate to zero (except the first one
  697. which is used to check that we are detecting non-zero matrices). The printout
  698. should state that it has found just one non-zero matrix.
  699.  
  700. Various versions of the make file (extension .mak) are included with the
  701. package. See the section on files [6].
  702.  
  703. The program also allocates and deletes a large block and small block of memory
  704. before it starts the main testing and then at the end of the test. It then
  705. checks that the blocks of memory were allocated in the same place. If not then
  706. one suspects that there has been a memory leak. i.e. a piece of memory has
  707. been allocated and not deleted.
  708.  
  709. This is not completely foolproof. Programs may allocate extra print buffers
  710. while the program is running. I have tried to overcome this by doing a print
  711. before I allocate the first memory block. Programs may allocate memory for
  712. different sized items in different places, or might not allocate items
  713. consecutively. Or they might mix the items with memory blocks from other
  714. programs. Nevertheless, I seem to get consistent answers from many of the
  715. compilers I am working with, so I think this is a worthwhile test.
  716.  
  717. If the DO_FREE_CHECK [2.2] option in include.h is activated, the program
  718. checks that each 'new' is balanced with exactly one 'delete'. This provides a
  719. more definitive test of no memory leaks. There are additional statements in
  720. myexcept.cpp which can be activated to print out details of the memory being
  721. allocated and released.
  722.  
  723. Several of the files have a line defining 'REPORT' that can be activated
  724. (deactivate the dummy version). This gives a printout of the number of times
  725. each of the 'REPORT' statements in the file is accessed. Use a grep with line
  726. numbers to locate the lines on which 'REPORT' occurs and compare these with
  727. the lines that the printout shows were actually accessed.
  728.  
  729.  
  730.         3  Reference manual
  731.         =  ========= ======
  732.  
  733.         Constructors                                 3.1
  734.         Accessing elements                           3.2
  735.         Assignment and copying                       3.3
  736.         Entering values                              3.4
  737.         Unary operations                             3.5
  738.         Binary operations                            3.6
  739.         Matrix and scalar ops                        3.7
  740.         Scalar functions                             3.8
  741.         Submatrices                                  3.9 
  742.         Change dimension                             3.10 
  743.         Change type                                  3.11 
  744.         Multiple matrix solve                        3.12 
  745.         Memory management                            3.13 
  746.         Efficiency                                   3.14 
  747.         Output                                       3.15 
  748.         Accessing unspecified type                   3.16 
  749.         Cholesky decomposition                       3.17 
  750.         QR decomposition                             3.18 
  751.         Singular value decomposition                 3.19
  752.         Eigenvalue decomposition                     3.20 
  753.         Sorting                                      3.21
  754.         Fast Fourier transform                       3.22 
  755.         Numerical recipes in C                       3.23
  756.         Exceptions                                   3.24 
  757.         Cleanup following exception                  3.25
  758.         Non-linear applications                      3.26 
  759.  
  760.  
  761.         3.1  Constructors
  762.         ===  ============
  763.  
  764. To construct an m x n matrix, 'A', (m and n are integers) use
  765.  
  766.     Matrix A(m,n);
  767.  
  768. The UpperTriangularMatrix, LowerTriangularMatrix, SymmetricMatrix and
  769. DiagonalMatrix types are square. To construct an n x n matrix use, for example
  770.  
  771.     UpperTriangularMatrix UT(n);
  772.     LowerTriangularMatrix LT(n);
  773.     SymmetricMatrix S(n);
  774.     DiagonalMatrix D(n);
  775.  
  776. Band matrices need to include bandwidth information in their constructors.
  777.  
  778.     BandMatrix BM(n, lower, upper);
  779.     UpperBandMatrix UB(n, upper);
  780.     LowerBandMatrix LB(n, lower);
  781.     SymmetrixBandMatrix SB(n, lower);
  782.  
  783. The integers upper and lower are the number of non-zero diagonals above and
  784. below the diagonal (excluding the diagonal) respectively.
  785.  
  786. The RowVector and ColumnVector types take just one argument in their
  787. constructors:
  788.  
  789.     RowVector RV(n);
  790.     ColumnVector CV(n);
  791.  
  792. You can also construct vectors and matrices without specifying the dimension.
  793. For example
  794.  
  795.     Matrix A;
  796.  
  797. In this case the dimension must be set by an assignment statement [3.3] or a
  798. re-dimension statement [3.10].
  799.  
  800. You can also use a constructor to set a matrix equal to another matrix or
  801. matrix expression.
  802.  
  803.     Matrix A = UT;
  804.     Matrix A = UT * LT;
  805.  
  806. Only conversions that don't lose information are supported - eg you cannot
  807. convert an upper triangular matrix into a diagonal matrix using =.
  808.  
  809.  
  810.  
  811.         3.2  Accessing elements
  812.         ===  ========= ========
  813.  
  814. Elements are accessed by expressions of the form 'A(i,j)' where i and j run
  815. from 1 to the appropriate dimension. Access elements of vectors with just one
  816. argument. Diagonal matrices can accept one or two subscripts.
  817.  
  818. This is different from the earliest version of the package in which the
  819. subscripts ran from 0 to one less than the appropriate dimension. Use
  820. 'A.element(i,j)' if you want this earlier convention.
  821.  
  822. 'A(i,j)' and 'A.element(i,j)' can appear on either side of an = sign.
  823.  
  824. If you activate the '#define SETUP_C_SUBSCRIPTS' in 'include.h' you can also
  825. access elements using the tradition C style notation. That is 'A[i][j]' for
  826. matrices (except diagonal) and 'V[i]' for vectors and diagonal matrices. The
  827. subscripts start at zero (ie like element) and there is no range checking.
  828. Because of the possibility of confusing 'V(i)' and 'V[i]', I suggest you do
  829. not activate this option unless you really want to use it.
  830.  
  831.  
  832.         3.3  Assignment and copying
  833.         ===  ========== === =======
  834.  
  835. The operator = is used for copying matrices, converting matrices, or
  836. evaluating expressions. For example
  837.  
  838.     A = B;  A = L;  A = L * U;
  839.  
  840. Only conversions that don't lose information are supported. The dimensions of
  841. the matrix on the left hand side are adjusted to those of the matrix or
  842. expression on the right hand side. Elements on the right hand side which are
  843. not present on the left hand side are set to zero.
  844.  
  845. The operator << can be used in place of = where it is permissible for
  846. information to be lost.
  847.  
  848. For example
  849.  
  850.     SymmetricMatrix S; Matrix A;
  851.     ......
  852.     S << A.t() * A;
  853.  
  854. is acceptable whereas
  855.  
  856.     S = A.t() * A;                            // error
  857.  
  858. will cause a runtime error since the package does not (yet?) recognise
  859. 'A.t()*A' as symmetric.
  860.  
  861. Note that you can not use << with constructors. For example
  862.  
  863.     SymmetricMatrix S << A.t() * A;           // error
  864.  
  865. does not work.
  866.  
  867. Also note that << cannot be used to load values from a full matrix into a band
  868. matrix, since it will be unable to determine the bandwidth of the band matrix.
  869.  
  870. A third copy routine is used in a similar role to =. Use
  871.  
  872.     A.Inject(D);
  873.  
  874. to copy the elements of 'D' to the corresponding elements of 'A' but leave the
  875. elements of 'A' unchanged if there is no corresponding element of 'D' (the =
  876. operator would set them to 0). This is useful, for example, for setting the
  877. diagonal elements of a matrix without disturbing the rest of the matrix.
  878. Unlike = and <<, Inject does not reset the dimensions of 'A', which must match
  879. those of 'D'. Inject does not test for no loss of information.
  880.  
  881. You cannot replace 'D' by a matrix expression. The effect of 'Inject(D)'
  882. depends on the type of 'D'. If 'D' is an expression it might not be obvious to
  883. the user what type it would have. So I thought it best to disallow
  884. expressions.
  885.  
  886. Inject can be used for loading values from a regular matrix into a band
  887. matrix. (Don't forget to zero any elements of the left hand side that will not
  888. be set by the loading operation).
  889.  
  890. Both << and Inject can be used with submatrix expressions on the left hand
  891. side. See the section on submatrices [3.9].
  892.  
  893. To set the elements of a matrix to a scalar use operator =
  894.  
  895.     Real r; Matrix A(m,n);
  896.     ......
  897.     Matrix A(m,n); A = r;
  898.  
  899.  
  900.  
  901.  
  902.         3.4  Entering values
  903.         ===  ======== ======
  904.  
  905. You can load the elements of a matrix from an array:
  906.  
  907.     Matrix A(3,2);
  908.     Real a[] = { 11,12,21,22,31,33 };
  909.     A << a;
  910.  
  911. This construction does not check that the numbers of elements match correctly.
  912. This version of << can be used with submatrices on the left hand side. It is
  913. not defined for band matrices.
  914.  
  915. Alternatively you can enter short lists using a sequence of numbers separated
  916. by << .
  917.  
  918.     Matrix A(3,2);
  919.     A << 11 << 12
  920.       << 21 << 22
  921.       << 31 << 32;
  922.  
  923. This does check for the correct total number of entries, although the message
  924. for there being insufficient numbers in the list may be delayed until the end
  925. of the block or the next use of this construction. This does not work for band
  926. matrices or submatrices, or for long lists. Also try to restrict its use to
  927. numbers. You can include expressions, but these must not call a function which
  928. includes the same construction.
  929.  
  930.  
  931.  
  932.         3.5  Unary operators
  933.         ===  ===== =========
  934.  
  935. The package supports unary operations
  936.  
  937.     X = -A      // change sign of elements
  938.     X = A.t()   // transpose
  939.     X = A.i()   // inverse (of square matrix A)
  940.  
  941.  
  942.  
  943.  
  944.         3.6  Binary operators
  945.         ===  ====== =========
  946.  
  947. The package supports binary operations
  948.  
  949.     X = A + B      // matrix addition
  950.     X = A - B      // matrix subtraction
  951.     X = A * B      // matrix multiplication
  952.     X = A.i() * B  // equation solve (square matrix A)
  953.     X = A | B      // concatenate horizontally (concatenate the rows)
  954.     X = A & B      // concatenate vertically (concatenate the columns)
  955.     X = SP(A, B)   // elementwise product of A and B (Schur product)
  956.  
  957.  
  958. Notes:
  959.  
  960. *  If you are doing repeated multiplication. For example 'A*B*C', use brackets
  961. to force the order of evaluation to minimize the number of operations. If 'C'
  962. is a column vector and 'A' is not a vector, then it will usually reduce the
  963. number of operations to use 'A*(B*C)'.
  964.  
  965. *  In the equation solve example case the inverse is not explicitly
  966. calculated. An LU decomposition of 'A' is performed and this is applied to
  967. 'B'. This is more efficient than calculating the inverse and then multiplying.
  968. See also multiple matrix solving [3.12].
  969.  
  970. *  The package does not (yet?) recognise 'B*A.i()' as an equation solve and
  971. the inverse of 'A' would be calculated. It is probably better to use
  972. '(A.t().i()*B.t()).t()'.
  973.  
  974. *  Horizontal or vertical concatenation returns a result of type Matrix,
  975. RowVector or ColumnVector.
  976.  
  977. *  If 'A' is m x p, 'B' is m x q, then 'A | B' is m x (p+q) with the k-th row
  978. being the elements of the k-th row of 'A' followed by the elements of the k-th
  979. row of 'B'.
  980.  
  981. *  If 'A' is p x n, 'B' is q x n, then 'A & B' is (p+q) x n with the k-th
  982. column being the elements of the k-th column of 'A' followed by the elements
  983. of the k-th column of 'B'.
  984.  
  985. *  For complicated concatenations of matrices, consider instead using
  986. submatrices [3.9].
  987.  
  988.  
  989.  
  990.  
  991.         3.7  Matrix and scalar
  992.         ===  ====== === ======
  993.  
  994. The following expression multiplies the elements of a matrix 'A' by a scalar
  995. f: 'A * f;' Likewise one can divide the elements of a matrix 'A' by a scalar
  996. f:' A / f;'
  997.  
  998. The expressions  'A + f' and 'A - f' add or subtract a rectangular matrix of
  999. the same dimension as 'A' with elements equal to 'f' to or from the matrix
  1000. 'A'.
  1001.  
  1002. In each case the matrix must be the first term in the expression. Expressions
  1003. such  'f + A'  or  'f * A'  are not recognised (yet?).
  1004.  
  1005.  
  1006.  
  1007.  
  1008.         3.8  Scalar functions of a matrix
  1009.         ===  ====== ========= == = ======
  1010.  
  1011.  
  1012.     int m = A.Nrows();                    // number of rows
  1013.     int n = A.Ncols();                    // number of columns
  1014.     Real ssq = A.SumSquare();             // sum of squares of elements
  1015.     Real sav = A.SumAbsoluteValue();      // sum of absolute values
  1016.     Real s = A.Sum();                     // sum of values
  1017.     Real mav = A.MaximumAbsoluteValue();  // maximum of absolute values
  1018.     Real norm = A.Norm1();                // maximum of sum of absolute
  1019.                                              values of elements of a column
  1020.     Real norm = A.NormInfinity();         // maximum of sum of absolute
  1021.                                              values of elements of a row
  1022.     Real t = A.Trace();                   // trace
  1023.     LogandSign ld = A.LogDeterminant();   // log of determinant
  1024.     Boolean z = A.IsZero();               // test all elements zero
  1025.     MatrixType mt = A.Type();             // type of matrix
  1026.     Real* s = Store();                    // pointer to array of elements
  1027.     int l = Storage();                    // length of array of elements
  1028.  
  1029. 'A.LogDeterminant()' returns a value of type LogandSign. If ld is of type
  1030. LogAndSign  use
  1031.  
  1032.     ld.Value()    to get the value of the determinant
  1033.     ld.Sign()     to get the sign of the determinant (values 1, 0, -1)
  1034.     ld.LogValue() to get the log of the absolute value.
  1035.  
  1036. 'A.IsZero()' returns Boolean value TRUE if the matrix 'A' has all elements
  1037. equal to 0.0.
  1038.  
  1039. 'MatrixType mt = A.Type()' returns the type of a matrix. Use '(char*)mt' to
  1040. get a string  (UT, LT, Rect, Sym, Diag, Band, UB, LB, Crout, BndLU) showing
  1041. the type (Vector types are returned as Rect).
  1042.  
  1043. The versions Sum(A), SumSquare(A), SumAbsoluteValue(A),
  1044. MaximumAbsoluteValue(A), Trace(A), LogDeterminant(A), Norm1(A),
  1045. NormInfinity(A)  can be used in place of A.Sum(), A.SumSquare(),
  1046. A.SumAbsoluteValue(), A.MaximumAbsoluteValue(), A.Trace(), A.LogDeterminant(),
  1047. A.Norm1(), A.NormInfinity().
  1048.  
  1049.  
  1050.  
  1051.         3.9  Submatrices
  1052.         ===  ===========
  1053.  
  1054.  
  1055.     A.SubMatrix(fr,lr,fc,lc)
  1056.  
  1057. This selects a submatrix from 'A'. The arguments  fr,lr,fc,lc are the first
  1058. row, last row, first column, last column of the submatrix with the numbering
  1059. beginning at 1. This may be used in any matrix expression or on the left hand
  1060. side of =, << or Inject. Inject does not check no information loss. You can
  1061. also use the construction
  1062.  
  1063.     Real c; .... A.SubMatrix(fr,lr,fc,lc) = c;
  1064.  
  1065. to set a submatrix equal to a constant.
  1066.  
  1067. The follwing are variants of SubMatrix:
  1068.  
  1069.     A.SymSubMatrix(f,l)             //   This assumes fr=fc and lr=lc.
  1070.     A.Rows(f,l)                     //   select rows
  1071.     A.Row(f)                        //   select single row
  1072.     A.Columns(f,l)                  //   select columns
  1073.     A.Column(f)                     //   select single column
  1074.  
  1075. In each case f and l mean the first and last row or column to be selected
  1076. (starting at 1).
  1077.  
  1078. If SubMatrix or its variant occurs on the right hand side of an = or << or
  1079. within an expression its type is as follows
  1080.  
  1081.     A.Submatrix(fr,lr,fc,lc):           If A is RowVector or
  1082.                                         ColumnVector then same type
  1083.                                         otherwise type Matrix
  1084.     A.SymSubMatrix(f,l):                Same type as A
  1085.     A.Rows(f,l):                        Type Matrix
  1086.     A.Row(f):                           Type RowVector
  1087.     A.Columns(f,l):                     Type Matrix
  1088.     A.Column(f):                        Type ColumnVector
  1089.  
  1090. If SubMatrix or its variant appears on the left hand side of  = or << , think
  1091. of its type being Matrix. Thus 'L.Row(1)' where 'L' is LowerTriangularMatrix
  1092. expects 'L.Ncols()' elements even though it will use only one of them. If you
  1093. are using = the program will check for no loss of data.
  1094.  
  1095. If you are are using the submatrix facility to build a matrix from a small
  1096. number of components, consider instead using the concatenation operators
  1097. [3.6].
  1098.  
  1099.  
  1100.  
  1101.         3.10  Change dimensions
  1102.         ====  ====== ==========
  1103.  
  1104. The following operations change the dimensions of a matrix. The values of the
  1105. elements are lost.
  1106.  
  1107.     A.ReDimension(nrows,ncols);     // for type Matrix or nricMatrix
  1108.     A.ReDimension(n);               // for all other types, except Band
  1109.     A.ReDimension(n,lower,upper);   // for BandMatrix
  1110.     A.ReDimension(n,lower);         // for LowerBandMatrix
  1111.     A.ReDimension(n,upper);         // for UpperBandMatrix
  1112.     A.ReDimension(n,lower);         // for SymmetricBandMatrix
  1113.  
  1114. Use   'A.CleanUp()'  to set the dimensions of 'A' to zero and release all the
  1115. heap memory.
  1116.  
  1117. Remember that 'ReDimension' destroys values. If you want to 'ReDimension', but
  1118. keep the values in the bit that is left use something like
  1119.  
  1120.    ColumnVector V(100);
  1121.    ...                            // load values
  1122.    V = V.Rows(1,50);              // to get first 50 values.
  1123.  
  1124. If you want to extend a matrix or vector use something like
  1125.  
  1126.    ColumnVector V(50);
  1127.    ...                            // load values
  1128.    { V.Release(); ColumnVector X=V; V.ReDimension(100); V.Rows(1,50)=X; }
  1129.                                   // V now length 100
  1130.  
  1131.  
  1132.  
  1133.  
  1134.         3.11  Change type
  1135.         ====  ====== ====
  1136.  
  1137. The following functions interpret the elements of a matrix (stored row by row)
  1138. to be a vector or matrix of a different type. Actual copying is usually
  1139. avoided where these occur as part of a more complicated expression.
  1140.  
  1141.     A.AsRow()
  1142.     A.AsColumn()
  1143.     A.AsDiagonal()
  1144.     A.AsMatrix(nrows,ncols)
  1145.     A.AsScalar()
  1146.  
  1147. The expression 'A.AsScalar()' is used to convert a 1 x 1 matrix to a scalar.
  1148.  
  1149.  
  1150.  
  1151.         3.12  Multiple matrix solve
  1152.         ====  ======== ====== =====
  1153.  
  1154. If 'A' is a square or symmetric matrix use
  1155.  
  1156.     CroutMatrix X = A;                // carries out LU decomposition
  1157.     Matrix AP = X.i()*P; Matrix AQ = X.i()*Q;
  1158.     LogAndSign ld = X.LogDeterminant();
  1159.  
  1160. rather than
  1161.  
  1162.     Matrix AP = A.i()*P; Matrix AQ = A.i()*Q;
  1163.     LogAndSign ld = A.LogDeterminant();
  1164.  
  1165. since each operation will repeat the LU decomposition.
  1166.  
  1167. If 'A' is a BandMatrix or a SymmetricBandMatrix begin with
  1168.  
  1169.     BandLUMatrix X = A;               // carries out LU decomposition
  1170.  
  1171. A CroutMatrix or a BandLUMatrix can't be manipulated or copied. Use references
  1172. as an alternative to copying.
  1173.  
  1174. Alternatively use
  1175.  
  1176.     LinearEquationSolver X = A;
  1177.  
  1178. This will choose the most appropiate decomposition of 'A'. That is, the band
  1179. form if 'A' is banded; the Crout decomposition if 'A' is square or symmetric
  1180. and no decomposition if 'A' is triangular or diagonal. If you want to use the
  1181. LinearEquationSolver '#include newmatap.h'.
  1182.  
  1183.  
  1184.  
  1185.         3.13  Memory management
  1186.         ====  ====== ==========
  1187.  
  1188. The package does not support delayed copy. Several strategies are required to
  1189. prevent unnecessary matrix copies.
  1190.  
  1191. Where a matrix is called as a function argument use a constant reference. For
  1192. example
  1193.  
  1194.     YourFunction(const Matrix& A)
  1195.  
  1196. rather than
  1197.  
  1198.     YourFunction(Matrix A)
  1199.  
  1200.  
  1201. Skip the rest of this section on your first reading.
  1202.  ------------------------------------------------------------------------------
  1203. Gnu g++ (< 2.6) users please read on; if you are returning matrix values from
  1204. a function, then you must use the ReturnMatrix construct.     
  1205.  ------------------------------------------------------------------------------
  1206.  
  1207. A second place where it is desirable to avoid unnecessary copies is when a
  1208. function is returning a matrix. Matrices can be returned from a function with
  1209. the return command as you would expect. However these may incur one and
  1210. possibly two copyings of the matrix. To avoid this use the following
  1211. instructions.
  1212.  
  1213. Make your function of type  ReturnMatrix . Then precede the return statement
  1214. with a Release statement (or a ReleaseAndDelete statement if the matrix was
  1215. created with new). For example
  1216.  
  1217.  
  1218.     ReturnMatrix MakeAMatrix()
  1219.     {
  1220.        Matrix A;
  1221.        ......
  1222.        A.Release(); return A;
  1223.     }
  1224.  
  1225. or
  1226.  
  1227.     ReturnMatrix MakeAMatrix()
  1228.     {
  1229.        Matrix* m = new Matrix;
  1230.        ......
  1231.        m->ReleaseAndDelete(); return *m;
  1232.     }
  1233.  
  1234. If your compiler objects to this code, replace the return statements with
  1235.  
  1236.     return A.ForReturn();
  1237.  
  1238. or
  1239.  
  1240.     return m->ForReturn();
  1241.  
  1242.  
  1243. If you are using AT&T C++ you may wish to replace  'return A;' by return
  1244. '(ReturnMatrix)A;'  to avoid a warning message; but this will give a runtime
  1245. error with Gnu. (You can't please everyone.)
  1246.  ------------------------------------------------------------------------------
  1247. Do not forget to make the function of type ReturnMatrix; otherwise you may get
  1248. incomprehensible run-time errors.                       
  1249.  ------------------------------------------------------------------------------
  1250. You can also use '.Release()' or '->ReleaseAndDelete()' to allow a matrix
  1251. expression to recycle space. Suppose you call
  1252.  
  1253.     A.Release();
  1254.  
  1255. just before 'A' is used just once in an expression. Then the memory used by
  1256. 'A' is either returned to the system or reused in the expression. In either
  1257. case, 'A''s memory is destroyed. This procedure can be used to improve
  1258. efficiency and reduce the use of memory.
  1259.  
  1260. Use '->ReleaseAndDelete' for matrices created by new if you want to completely
  1261. delete the matrix after it is accessed.
  1262.  
  1263.  
  1264.  
  1265.         3.14  Efficiency
  1266.         ====  ==========
  1267.  
  1268. The package tends to be not very efficient for dealing with matrices with
  1269. short rows. This is because some administration is required for accessing rows
  1270. for a variety of types of matrices. To reduce the administration a special
  1271. multiply routine is used for rectangular matrices in place of the generic one.
  1272. Where operations can be done without reference to the individual rows (such as
  1273. adding matrices of the same type) appropriate routines are used.
  1274.  
  1275. When you are using small matrices (say smaller than 10 x 10) you may find it
  1276. faster to use rectangular matrices rather than the triangular or symmetric
  1277. ones.
  1278.  
  1279.  
  1280.  
  1281.         3.15  Output
  1282.         ====  ======
  1283.  
  1284. To print a matrix use an expression like
  1285.  
  1286.     Matrix A;
  1287.     ......
  1288.     cout << setw(10) << setprecision(5) << A;
  1289.  
  1290. This will work only with systems that support the AT&T input/output routines
  1291. including manipulators. You need to #include the file newmat9.h.
  1292.  
  1293. The present version of this routine is useful only for matrices small enough
  1294. to fit within a page or screen width.
  1295.  
  1296. To print several vectors or matrices in columns use a concatenation operator
  1297. [3.6]:
  1298.  
  1299.    Matrix A, B;
  1300.    .....
  1301.    cout << setw(10) << setprecision(5) << (A | B);
  1302.  
  1303.  
  1304.  
  1305.  
  1306.         3.16  Unspecified type
  1307.         ====  =========== ====
  1308.  
  1309. Skip this section on your first reading.
  1310.  
  1311. If you want to work with a matrix of unknown type, say in a function. You can
  1312. construct a matrix of type 'GenericMatrix'. Eg
  1313.  
  1314.    Matrix A;
  1315.    .....                                  // put some values in A
  1316.    GenericMatrix GM = A;
  1317.  
  1318. A GenericMatrix matrix can be used anywhere where a matrix expression can be
  1319. used and also on the left hand side of an '='. You can pass any type of matrix
  1320. (excluding the Crout and BandLUMatrix types) to a 'const GenericMatrix&'
  1321. argument in a function. However most scalar functions including Nrows(),
  1322. Ncols(), Type() and element access do not work with it. Nor does the
  1323. ReturnMatrix construct. See also the paragraph on LinearEquationSolver [3.12].
  1324.  
  1325. An alternative and less flexible approach is to use Basematrix or
  1326. GeneralMatrix.
  1327.  
  1328. Suppose you wish to write a function which accesses a matrix of unknown type
  1329. including expressions (eg 'A*B'). Then use a layout similar to the following:
  1330.  
  1331.    void YourFunction(BaseMatrix& X)
  1332.    {
  1333.       GeneralMatrix* gm = X.Evaluate();   // evaluate an expression
  1334.                                           // if necessary
  1335.       ........                            // operations on *gm
  1336.       gm->tDelete();                      // delete *gm if a temporary
  1337.    }
  1338.  
  1339. See, as an example, the definitions of 'operator<<' in newmat9.cxx.
  1340.  
  1341. Under certain circumstances; particularly where 'X' is to be used just once in
  1342. an expression you can leave out the 'Evaluate()' statement and the
  1343. corresponding 'tDelete()'. Just use 'X' in the expression.
  1344.  
  1345. If you know YourFunction will never have to handle a formula as its argument
  1346. you could also use
  1347.  
  1348.    void YourFunction(const GeneralMatrix& X)
  1349.    {
  1350.       ........                            // operations on X
  1351.    }
  1352.  
  1353. Do not try to construct a GeneralMatrix or BaseMatrix.
  1354.  
  1355.  
  1356.  
  1357.         3.17  Cholesky decomposition
  1358.         ====  ======== =============
  1359.  
  1360. Suppose S is symmetric and positive definite. Then there exists a unique lower
  1361. triangular matrix L such that L * L.t() = S. To calculate this use
  1362.  
  1363.     SymmetricMatrix S;
  1364.     ......
  1365.     LowerTriangularMatrix L = Cholesky(S);
  1366.  
  1367. If S is a symmetric band matrix then L is a band matrix and an alternative
  1368. procedure is provied for carrying out the decomposition:
  1369.  
  1370.     SymmetricBandMatrix S;
  1371.     ......
  1372.     LowerBandMatrix L = Cholesky(S);
  1373.  
  1374.  
  1375.  
  1376.  
  1377.         3.18  QR decomposition
  1378.         ====  == =============
  1379.  
  1380. This is a variant on the usual QR transformation.
  1381.  
  1382. Start with matrix
  1383.  
  1384.        / 0    0 \      s
  1385.        \ X    Y /      n
  1386.  
  1387.          s    t
  1388.  
  1389. Our version of the QR decomposition multiplies this matrix by an orthogonal
  1390. matrix Q to get
  1391.  
  1392.        / U    M \      s
  1393.        \ 0    Z /      n
  1394.  
  1395.          s    t
  1396.  
  1397. where 'U' is upper triangular (the R of the QR transform).
  1398.  
  1399. This is good for solving least squares problems: choose b (matrix or row
  1400. vector) to minimize the sum of the squares of the elements of
  1401.  
  1402.          Y - X*b
  1403.  
  1404. Then choose 'b = U.i()*M;' The residuals 'Y - X*b' are in 'Z'.
  1405.  
  1406. This is the usual QR transformation applied to the matrix 'X' with the square
  1407. zero matrix attached concatenated on top of it. It gives the same triangular
  1408. matrix as the QR transform applied directly to 'X' and generally seems to work
  1409. in the same way as the usual QR transform. However it fits into the matrix
  1410. package better and also gives us the residuals directly. It turns out to be
  1411. essentially a modified Gram-Schmidt decomposition.
  1412.  
  1413. Two routines are provided:
  1414.  
  1415.     QRZ(X, U);
  1416.  
  1417. replaces 'X' by orthogonal columns and forms 'U'.
  1418.  
  1419.     QRZ(X, Y, M);
  1420.  
  1421. uses 'X' from the first routine, replaces 'Y' by 'Z' and forms 'M'.
  1422.  
  1423. The are also two routines 'QRZT(X, L)' and 'QRZT(X, Y, M)' which do the same
  1424. decomposition on the transposes of all these matrices. QRZT replaces the
  1425. routines HHDecompose in earlier versions of newmat. HHDecompose is still
  1426. defined but just calls QRZT.
  1427.  
  1428.  
  1429.  
  1430.         3.19  Singular value decomposition
  1431.         ====  ======== ===== =============
  1432.  
  1433. The singular value decomposition of an m x n matrix 'A' (where m >= n) is a
  1434. decomposition
  1435.  
  1436.     A  = U * D * V.t()
  1437.  
  1438. where 'U' is m x n with  'U.t() * U'  equalling the identity, 'D' is an n x n
  1439. diagonal matrix and 'V' is an n x n orthogonal matrix.
  1440.  
  1441. Singular value decompositions are useful for understanding the structure of
  1442. ill-conditioned matrices, solving least squares problems, and for finding the
  1443. eigenvalues of 'A.t() * A'.
  1444.  
  1445. To calculate the singular value decomposition of 'A' (with m >= n) use one of
  1446.  
  1447.     SVD(A, D, U, V);                  // U (= A is OK)
  1448.     SVD(A, D);
  1449.     SVD(A, D, U);                     // U (= A is OK)
  1450.     SVD(A, D, U, FALSE);              // U (can = A) for workspace only
  1451.     SVD(A, D, U, V, FALSE);           // U (can = A) for workspace only
  1452.  
  1453. The values of 'A' are not changed unless 'A' is also inserted as the third
  1454. argument.
  1455.  
  1456.  
  1457.  
  1458.         3.20  Eigenvalue decomposition
  1459.         ====  ========== =============
  1460.  
  1461. An eigenvalue decomposition of a symmetric matrix 'A' is a decomposition
  1462.  
  1463.     A  = V * D * V.t()
  1464.  
  1465. where 'V' is an orthogonal matrix and 'D' is a diagonal matrix.
  1466.  
  1467. Eigenvalue analyses are used in a wide variety of engineering, statistical and
  1468. other mathematical analyses.
  1469.  
  1470. The package includes two algorithms: Jacobi and Householder. The first is
  1471. extremely reliable but much slower than the second.
  1472.  
  1473. The code is adapted from routines in "Handbook for Automatic Computation, Vol
  1474. II, Linear Algebra" by Wilkinson and Reinsch, published by Springer Verlag. 
  1475.  
  1476.  
  1477.     Jacobi(A,D,S,V);                  // A, S symmetric; S is workspace,
  1478.                                       //    S = A is OK; V is a matrix
  1479.     Jacobi(A,D);                      // A symmetric
  1480.     Jacobi(A,D,S);                    // A, S symmetric; S is workspace,
  1481.                                       //    S = A is OK
  1482.     Jacobi(A,D,V);                    // A symmetric; V is a matrix
  1483.  
  1484.     EigenValues(A,D);                 // A symmetric
  1485.     EigenValues(A,D,S);               // A, S symmetric; S is for back
  1486.                                       //    transforming, S = A is OK
  1487.     EigenValues(A,D,V);               // A symmetric; V is a matrix
  1488.  
  1489. The values of 'A' are not changed unless 'A' is also inserted as the third
  1490. argument. If you need eigenvectors use one of the forms with matrix 'V'. The
  1491. eigenvectors are returned as the columns of 'V'.
  1492.  
  1493.  
  1494.  
  1495.  
  1496.         3.21  Sorting
  1497.         ====  =======
  1498.  
  1499. To sort the values in a matrix or vector, 'A', (in general this operation
  1500. makes sense only for vectors and diagonal matrices) use
  1501.  
  1502.     SortAscending(A);
  1503.  
  1504. or
  1505.  
  1506.     SortDescending(A);
  1507.  
  1508. I use the Shell-sort algorithm. This is a medium speed algorithm, you might
  1509. want to replace it with something faster if speed is critical and your
  1510. matrices are large.
  1511.  
  1512.  
  1513.  
  1514.         3.22  Fast Fourier transform
  1515.         ====  ==== ======= =========
  1516.  
  1517.  
  1518.    FFT(X, Y, F, G);                         // F=X and G=Y are OK
  1519.  
  1520. where X, Y, F, G are column vectors. X and Y are the real and imaginary input
  1521. vectors; F and G are the real and imaginary output vectors. The lengths of X
  1522. and Y must be equal and should be the product of numbers less than about 10
  1523. for fast execution.
  1524.  
  1525. The formula is
  1526.  
  1527.           n-1
  1528.    h[k] = SUM  z[j] exp (-2 pi i jk/n)
  1529.           j=0
  1530.  
  1531. where z[j] is stored complex and stored in X(j+1) and Y(j+1). Likewise h[k] is
  1532. complex and stored in F(k+1) and G(k+1). The fast Fourier algorithm takes
  1533. order n log(n) operations (for "good" values of n) rather than n**2 that
  1534. straight evaluation would take.
  1535.  
  1536. I use the method of Carl de Boor (1980), "Siam J Sci Stat Comput", pp 173-8.
  1537. The sines and cosines are calculated explicitly. This gives better accuracy,
  1538. at an expense of being a little slower than is otherwise possible.
  1539.  
  1540. Related functions
  1541.  
  1542.    FFTI(F, G, X, Y);                        // X=F and Y=G are OK
  1543.    RealFFT(X, F, G);
  1544.    RealFFTI(F, G, X);
  1545.  
  1546. 'FFTI' is the inverse trasform for 'FFT'. 'RealFFT' is for the case when the
  1547. input vector is real, that is Y = 0. I assume the length of X, denoted by n,
  1548. is even. The program sets the lengths of F and G to n/2 + 1. 'RealFFTI' is the
  1549. inverse of 'RealFFT'.
  1550.  
  1551.  
  1552.  
  1553.         3.23  Interface to Numerical Recipes in C
  1554.         ====  ========= == ========= ======= == =
  1555.  
  1556. This package can be used with the vectors and matrices defined in "Numerical
  1557. Recipes in C". You need to edit the routines in Numerical Recipes so that the
  1558. elements are of the same type as used in this package. Eg replace float by
  1559. double, vector by dvector and matrix by dmatrix, etc. You will also need to
  1560. edit the function definitions to use the version acceptable to your compiler.
  1561. Then enclose the code from Numerical Recipes in  extern "C" { ... }. You will
  1562. also need to include the matrix and vector utility routines.
  1563.  
  1564. Then any vector in Numerical Recipes with subscripts starting from 1 in a
  1565. function call can be accessed by a RowVector, ColumnVector or DiagonalMatrix
  1566. in the present package. Similarly any matrix with subscripts starting from 1
  1567. can be accessed by an  nricMatrix  in the present package. The class
  1568. nricMatrix is derived from Matrix and can be used in place of Matrix. In each
  1569. case, if you wish to refer to a RowVector, ColumnVector, DiagonalMatrix or
  1570. nricMatrix X in an function from Numerical Recipes, use X.nric() in the
  1571. function call.
  1572.  
  1573. Numerical Recipes cannot change the dimensions of a matrix or vector. So
  1574. matrices or vectors must be correctly dimensioned before a Numerical Recipes
  1575. routine is called.
  1576.  
  1577. For example
  1578.  
  1579.    SymmetricMatrix B(44);
  1580.    .....                             // load values into B
  1581.    nricMatrix BX = B;                // copy values to an nricMatrix
  1582.    DiagonalMatrix D(44);             // Matrices for output
  1583.    nricMatrix V(44,44);              //    correctly dimensioned
  1584.    int nrot;
  1585.    jacobi(BX.nric(),44,D.nric(),V.nric(),&nrot);
  1586.                                      // jacobi from NRIC
  1587.    cout << D;                        // print eigenvalues
  1588.  
  1589.  
  1590.  
  1591.  
  1592.         3.24  Exceptions
  1593.         ====  ==========
  1594.  
  1595. This package includes a partial implementation of exceptions for compilers
  1596. which do not support C++ exceptions. I used Carlos Vidal's article in the
  1597. September 1992 "C Users Journal" as a starting point.
  1598.  
  1599. See customising [2.2] for selecting the correct exception option.
  1600.  
  1601. See the section on error messages [4] for some notes on the messages generated
  1602. by the exceptions.
  1603.  
  1604. The rest of this section describes my exception simulation package. But see
  1605. the end of the section for controlling the action after an exception has been
  1606. generated.
  1607.  
  1608. Newmat does a partial clean up of memory following throwing an exception - see
  1609. the next section. However, the present version will leave a little heap memory
  1610. unrecovered under some circumstances. I would not expect this to be a major
  1611. problem, but it is something that needs to be sorted out.
  1612.  
  1613. The functions/macros I define are Try, Throw, Catch, CatchAll and
  1614. CatchAndThrow. Try, Throw, Catch and CatchAll correspond to try, throw, catch
  1615. and catch(...) in the C++ standard. A list of Catch clauses must be terminated
  1616. by either CatchAll or CatchAndThrow but not both. Throw takes an Exception as
  1617. an argument or takes no argument (for passing on an exception). I do not have
  1618. a version of Throw for specifying which exceptions a function might throw.
  1619. Catch takes an exception class name as an argument; CatchAll and CatchAndThrow
  1620. don't have any arguments. Try, Catch and CatchAll must be followed by blocks
  1621. enclosed in curly brackets.
  1622.  
  1623. I have added another macro Bounce to mean a rethrow, Throw(). This was
  1624. necessary to enable the package to be compatible with both my exception
  1625. package and C++ exceptions.
  1626.  
  1627. All Exceptions must be derived from a class, Exception, defined in newmat and
  1628. can contain only static variables. See the examples in newmat if you want to
  1629. define additional exceptions.
  1630.  
  1631. I have defined 5 clases of exceptions for users (there are others but I
  1632. suggest you stick to these ones):
  1633.  
  1634.    SpaceException                 Insufficient space on the heap
  1635.    ProgramException               Errors such as out of range index or
  1636.                                   incompatible matrix types or
  1637.                                   dimensions
  1638.    ConvergenceException           Iterative process does not converge
  1639.    DataException                  Errors such as attempting to invert a
  1640.                                   singular matrix
  1641.    InternalException              Probably a programming error in newmat
  1642.  
  1643. For each of these exception classes, I have defined a member function 'void
  1644. SetAction(int)'. If you call 'SetAction(1)', and a corresponding exception
  1645. occurs, you will get an error message. If there is a Catch clause for that
  1646. exception, execution will be passed to that clause, otherwise the program will
  1647. exit. If you call 'SetAction(0)' you will get the same response, except that
  1648. there will be no error message. If you call 'SetAction(-1)', you will get the
  1649. error message but the program will always exit.
  1650.  
  1651.  
  1652.  
  1653.         3.25  Cleanup after an exception
  1654.         ====  ======= ===== == =========
  1655.  
  1656. The exception mechanisms in newmat are based on the C functions setjmp and
  1657. longjmp. These functions do not call destructors so can lead to garbage being
  1658. left on the heap. (I refer to memory allocated by "new" as heap memory). For
  1659. example, when you call
  1660.  
  1661.    Matrix A(20,30);
  1662.  
  1663. a small amount of space is used on the stack containing the row and column
  1664. dimensions of the matrix and 600 doubles are allocated on the heap for the
  1665. actual values of the matrix. At the end of the block in which A is declared,
  1666. the destructor for A is called and the 600 doubles are freed. The locations on
  1667. the stack are freed as part of the normal operations of the stack. If you
  1668. leave the block using a longjmp command those 600 doubles will not be freed
  1669. and will occupy space until the program terminates.
  1670.  
  1671. To overcome this problem newmat keeps a list of all the currently declared
  1672. matrices and its exception mechanism will return heap memory when you do a
  1673. Throw and Catch.
  1674.  
  1675. However it will not return heap memory from objects from other packages. If
  1676. you want the mechanism to work with another class you will have to do four
  1677. things:
  1678.  
  1679. 1:  derive your class from class Janitor defined in except.h;
  1680.  
  1681. 2:  define a function 'void CleanUp()' in that class to return all heap
  1682. memory;
  1683.  
  1684. 3:   include the following lines in the class definition
  1685.  
  1686.       public:
  1687.          void* operator new(size_t size)
  1688.          { do_not_link=TRUE; void* t = ::operator new(size); return t; }
  1689.          void operator delete(void* t) { ::operator delete(t); }
  1690.  
  1691. 4:   be sure to include a copy constructor in you class definition, that is,
  1692. something like
  1693.  
  1694.       X(const X&);
  1695.  
  1696.  
  1697. Note that the function 'CleanUp()' does somewhat the same duties as the
  1698. destructor. However 'CleanUp()' has to do the "cleaning" for the class you are
  1699. working with and also the classes it is derived from. So it will often be
  1700. wrong to use exactly the same code for both 'CleanUp()' and the destructor or
  1701. to define your destructor as a call to 'CleanUp()'.
  1702.  
  1703.  
  1704.  
  1705.  
  1706.         3.26  Non-linear applications
  1707.         ====  ========== ============
  1708.  
  1709. Files solution.h, solution.cpp contain a class for solving for x in y = f(x)
  1710. where x is a one-dimensional continuous monotonic function. This is not a
  1711. matrix thing at all but is included because it is a useful thing and because
  1712. it is a simpler version of the technique used in the non-linear least squares.
  1713.  
  1714. Files newmatnl.h, newmatnl.cpp contain a series of classes for non-linear
  1715. least squares, to be extended to maximum likelihood in a later release.
  1716.  
  1717. Documentation for both of these is in the definition files. Simple examples
  1718. are in sl_ex.cpp and nl_ex.cpp.
  1719.  
  1720. These packages do not work with the AT&T [2.3.1] and HPUX [2.3.4] compilers
  1721. and newmatnl is questionable under Sun 4.0.1 [2.3.6].
  1722.  
  1723.  
  1724.  
  1725.         4  Error messages
  1726.         =  ===== ========
  1727.  
  1728. Most error messages are self-explanatory. The message gives the size of the
  1729. matrices involved. Matrix types are referred to by the following codes:
  1730.  
  1731.    Matrix or vector                    1
  1732.    Symmetric matrix                    5
  1733.    Band matrix                         9
  1734.    Symmetric band matrix              13
  1735.    Lower triangular matrix            17
  1736.    Lower triangular band matrix       25
  1737.    Upper triangular matrix            33
  1738.    Upper triangular band matrix       41
  1739.    Diagonal matrix                    63
  1740.    Crout matrix (LU matrix)           65
  1741.    Band LU matrix                     73
  1742.  
  1743. Other codes should not occur.
  1744.  
  1745. See the section on exceptions [3.24] for more details on the structure of the
  1746. exception classes.
  1747.  
  1748. I have defined a class Tracer that is intended to help locate the place where
  1749. an error has occurred. At the beginning of a function I suggest you include a
  1750. statement like
  1751.  
  1752.    Tracer tr("name");
  1753.  
  1754. where name is the name of the function. This name will be printed as part of
  1755. the error message, if an exception occurs in that function, or in a function
  1756. called from that function. You can change the name as you proceed through a
  1757. function with the ReName function
  1758.  
  1759.    tr.ReName("new name");
  1760.  
  1761. if, for example, you want to track progress through the function.
  1762.  
  1763.  
  1764.  
  1765.  
  1766.         5  Bugs
  1767.         =  ====
  1768.  
  1769.  
  1770. *  Small memory leaks may occur when an exception is thrown and caught.
  1771.  
  1772. *  My exception scheme is not properly linked in with the standard library
  1773. exceptions. In particular, my scheme may fail to catch out-of-memory
  1774. exceptions.
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.         6  List of files
  1782.         =  ==== == =====
  1783.  
  1784.  
  1785.  README          readme file
  1786.  NEWMATA  TXT    documentation file
  1787.  NEWMATB  TXT    notes on the package design
  1788.  KBRIGGS  TXT    Keith Briggs' list of matrix libraries
  1789.  
  1790.  BOOLEAN  H      boolean class definition
  1791.  CONTROLW H      control word definition file
  1792.  INCLUDE  H      details of include files and options
  1793.  MYEXCEPT H      general exception handler definitions
  1794.  NEWMAT   H      main matrix class definition file
  1795.  NEWMATAP H      applications definition file
  1796.  NEWMATIO H      input/output definition file
  1797.  NEWMATNL H      non-linear optimisation definition file
  1798.  NEWMATRC H      row/column functions definition files
  1799.  NEWMATRM H      rectangular matrix access definition files
  1800.  PRECISIO H      numerical precision constants
  1801.  SOLUTION H      one dimensional solve definition file
  1802.  
  1803.  BANDMAT  CPP    band matrix routines
  1804.  CHOLESKY CPP    Cholesky decomposition
  1805.  EVALUE   CPP    eigenvalues and eigenvector calculation
  1806.  FFT      CPP    fast Fourier transform
  1807.  HHOLDER  CPP    QR routines
  1808.  JACOBI   CPP    eigenvalues by the Jacobi method
  1809.  MYEXCEPT CPP    general error and exception handler
  1810.  NEWMAT1  CPP    type manipulation routines
  1811.  NEWMAT2  CPP    row and column manipulation functions
  1812.  NEWMAT3  CPP    row and column access functions
  1813.  NEWMAT4  CPP    constructors, redimension, utilities
  1814.  NEWMAT5  CPP    transpose, evaluate, matrix functions
  1815.  NEWMAT6  CPP    operators, element access
  1816.  NEWMAT7  CPP    invert, solve, binary operations
  1817.  NEWMAT8  CPP    LU decomposition, scalar functions
  1818.  NEWMAT9  CPP    output routines
  1819.  NEWMATEX CPP    matrix exception handler
  1820.  NEWMATNL CPP    non-linear optimisation
  1821.  NEWMATRM CPP    rectangular matrix access functions
  1822.  SORT     CPP    sorting functions
  1823.  SOLUTION CPP    one dimensional solve
  1824.  SUBMAT   CPP    submatrix functions
  1825.  SVD      CPP    singular value decomposition
  1826.  
  1827.  EXAMPLE  CPP    example of use of package
  1828.  EXAMPLE  TXT    output from example
  1829.  
  1830.  GNU      MAK    general make file for Gnu G++
  1831.  CC       MAK    general make file for AT&T, Sun and HPUX
  1832.  MS_NT    MAK    general make file for Microsoft C 8.0 (windows NT)
  1833.  WATCOM   MAK    general make file for Watcom 10
  1834.  WATCO_NT MAK    general make file for Watcom 10 (windows NT)
  1835.  EX_B     MAK    make file for example for Borland C 3.1
  1836.  EX_BC45  MAK    make file for example for Borland C 4.5 (windows NT)
  1837.  TMT_B    MAK    make file for test for Borland C 3.1
  1838.  TMT_BC45 MAK    make file for test for Borland C 4.5 (windows NT)
  1839.  TMT_Z    MAK    make file for test for Zortech
  1840.  
  1841.  SL_EX    CPP    example of OneDimSolve routine
  1842.  SL_EX    TXT    output from example
  1843.  NL_EX    CPP    example of non-linear least squares
  1844.  NL_EX    TXT    output from example
  1845.  
  1846.  
  1847. See the section on testing [2.6] for details of test files.
  1848.  
  1849.  
  1850.  
  1851.         7  Problem report form
  1852.         =  ======= ====== ====
  1853.  
  1854. Copy and paste this to your editor; fill it out and email to
  1855.     robert.davies@vuw.ac.nz
  1856.  
  1857. or
  1858.  
  1859.     Compuserve 72777,656.
  1860.  
  1861.  Version: ............... newmat08 (19 Jan 95)
  1862.  Primary site ........... Compuserve
  1863.  Downloaded from: .......
  1864.  Your email address: ....
  1865.  Today's date: ..........
  1866.  Your machine: ..........
  1867.  Operating system: ......
  1868.  Compiler & version: ....
  1869.  Describe the problem - attach examples if possible:
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.